package com.smile.config;

import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class NacosMetadataListener implements ApplicationListener<ApplicationEnvironmentPreparedEvent> {
    @Override
    public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
        String contextPath = event.getEnvironment().getProperty("server.servlet.context-path", "");
        System.setProperty("spring.cloud.nacos.discovery.metadata.route.path", contextPath);
    }
}
